package com.example.youzhengyang

import androidx.room.*
import kotlinx.coroutines.flow.Flow

// 1. DAO 接口定义
@Dao
interface WordDao {
    // 查询所有单词
    @Query("SELECT * FROM words")
    fun getAllWords(): Flow<List<Word>>

    // 插入单词
    @Insert
    suspend fun insert(word: Word)

    // 删除单词
    @Delete
    suspend fun delete(word: Word)
}

// 2. 数据库类定义
@Database(entities = [Word::class], version = 1, exportSchema = false)
abstract class WordDatabase : RoomDatabase() {
    // 提供 DAO 访问方法
    abstract fun wordDao(): WordDao
} 